import React from 'react'
import { Route, Switch } from 'react-router-dom'
import Bundle from './bundle.js'; //按需加载

import NotFound from '../view/404'; //404页面
import HomeContainer from 'bundle-loader?lazy&name=[name]!../view/home';
import OrderContainer from 'bundle-loader?lazy&name=[name]!../view/order';
import OrderTakeContainer from 'bundle-loader?lazy&name=[name]!../view/order/take';
import OrderVisitContainer from 'bundle-loader?lazy&name=[name]!../view/order/visit';

//首页
const Home = () => (
    <Bundle load={HomeContainer}>
        {(Home) => <Home />}
    </Bundle>
);

//预约洗车
const Order = () => (
    <Bundle load={OrderContainer}>
        {(Order) => <Order />}
    </Bundle>
);
//预约洗车-取车到店
const OrderTake = () => (
    <Bundle load={OrderTakeContainer}>
        {(OrderTake) => <OrderTake />}
    </Bundle>
);
//预约洗车-上门洗车
const OrderVisit = () => (
    <Bundle load={OrderVisitContainer}>
        {(OrderVisit) => <OrderVisit />}
    </Bundle>
);


class routes extends React.Component {
    render() {
        return <Switch>
            <Route exact path="/" component={Home}></Route>
            <Route path="/order/take" component={OrderTake}></Route>
            <Route path="/order/visit" component={OrderVisit}></Route>
            <Route path="/order" component={Order}></Route>
            <Route component={NotFound}></Route>
        </Switch>
    }
}

export default routes